#ifndef __RAYTRACER_IMAGE_H__
#define __RAYTRACER_IMAGE_H__

#include <boost/scoped_array.hpp>
#include <boost/make_shared.hpp>
#include <boost/enable_shared_from_this.hpp>

#include "pixeltype.h"

namespace raytracer {

class ImageFactory;

template<typename DataType,typename PixelType=rgb_t>
class Image
   : public boost::enable_shared_from_this<
      Image<DataType,PixelType> >
{
public:

typedef boost::shared_ptr< Image<DataType,PixelType> > ImagePtr;

friend ImagePtr boost::make_shared<>();
friend ImagePtr boost::make_shared<>(const size_t&,const size_t&);

   size_t width() const;
   size_t height() const;
   size_t channels() const;
   size_t size() const;

   DataType * begin();
   DataType * end();

   const DataType * begin() const;
   const DataType * end() const;

   void recreate(
      const size_t &a_width,
      const size_t &a_height);

   virtual ~Image();

   ImagePtr getImagePtr();

protected:

   Image();
   Image(const size_t &a_width, const size_t &a_height);

   boost::scoped_array<DataType> m_data;
   size_t                        m_width;
   size_t                        m_height;

private:
   //purposely not implemented
//   Image(const Image &);
//   virtual Image& operator=(const Image &);
};

} //end of namespace

#endif //__RAYTRACER_IMAGE_H__
